package model

import "time"

type Download struct {
	ID             string     `gorm:"primaryKey;column:id" json:"id"`
	VideoID        string     `gorm:"column:video_id" json:"video_id"`
	Status         string     `gorm:"column:status" json:"status"`
	Progress       int        `gorm:"column:progress;default:0" json:"progress"`
	FilePath       string     `gorm:"column:file_path" json:"file_path"`
	FileSize       int64      `gorm:"column:file_size" json:"file_size"`
	DownloadedSize int64      `gorm:"column:downloaded_size;default:0" json:"downloaded_size"`
	Speed          int        `gorm:"column:speed;default:0" json:"speed"`
	ErrorMessage   string     `gorm:"column:error_message" json:"error_message"`
	StartedAt      time.Time  `gorm:"column:started_at;type:datetime" json:"started_at"`
	CompletedAt    *time.Time `gorm:"column:completed_at;type:datetime" json:"completed_at"`
	CreatedAt      time.Time  `gorm:"column:created_at;type:datetime" json:"created_at"`
	UpdatedAt      time.Time  `gorm:"column:updated_at;type:datetime" json:"updated_at"`
}

func (Download) TableName() string {
	return "douyin_downloads"
}